package code.part03_exception;

import java.util.Scanner;

/**
 * @author: ZJT
 * @Time: 2021/7/13
 * @Description: 异常
 */
public class P01_Exception {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        try {
            System.out.print("请输入被除数:");
            int num1 = in.nextInt();
            System.out.print("请输入除数:");
            int num2 = in.nextInt();
            try {
                System.out.println(String.format("%d / %d = %d",
                        num1, num2, num1 / num2));
            } catch (Exception e) {
                System.out.println("异常嵌套抓捕就近原则");
            }
            System.out.println("同一个异常多次抓捕适用于循环处理时，某次异常不影响后续操作");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.out.println("finally");
        }
    }
}
